<?php
error_reporting(0);
include 'check.php';
include_once '../comm/conn.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="5" leftmargin="0">
<table width="700" border="0">
<tr>
<td style="padding-left:10px; font-size:20px; color:#990000; font-weight:bold">多多返利系统7.1专用数据库检测修复工具(2011.6.11)</td>
</tr>
<tr>
<td style="padding-left:10px;"><?php
$link = mysql_connect($dbserver, $dbuser, $dbpass);
mysql_query("set names utf8");
mysql_select_db($dbname);
$i=0;$j=0;

$sql="ALTER TABLE `".$BIAOTOU."websetting` modify column `keyword` varchar(1000),modify column `description` varchar(2000),modify column `url` varchar(100),modify column `surl` varchar(100),modify column `email` varchar(100),modify column `icp` varchar(100),modify column `liebiao` varchar(50),modify column `wjt` varchar(50),modify column `morensort` varchar(50),modify column `moban` varchar(50),modify column `miyue` varchar(50);";
mysql_query($sql);

$ad = array(
  id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  content=>"`content` varchar(5000) DEFAULT NULL",
  adtype=>"`adtype` varchar(255) DEFAULT NULL",
  addtime=>"`addtime` varchar(255) DEFAULT NULL",
);

$article = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  cid=>"`cid` int(11) DEFAULT NULL",
  title=>"`title` varchar(200) DEFAULT ''",
  subtitle=>"`subtitle` varchar(200) DEFAULT ''",
  att=>"`att` set('a','b','c','d','e','f','g') DEFAULT ''",
  pic=>"`pic` varchar(200) DEFAULT NULL",
  source=>"`source` varchar(200) DEFAULT NULL",
  author=>"`author` varchar(20) DEFAULT NULL",
  resume=>"`resume` varchar(500) DEFAULT NULL",
  pubdate=>"`pubdate` varchar(40) DEFAULT ''",
  content=>"`content` text",
  hits=>"`hits` int(11) DEFAULT '0'",
  created_by=>"`created_by` int(11) DEFAULT NULL",
  created_date=>"`created_date` datetime DEFAULT NULL",
  delete_session_id=>"`delete_session_id` int(11) DEFAULT NULL",
  ontop=>"`ontop` int(11) DEFAULT 0",
  hot=>"`hot` int(11) DEFAULT 0",
);

$category = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  pid=>"`pid` int(11) DEFAULT '0'",
  name=>"`name` varchar(50) DEFAULT ''",
  description=>"`description` text",
  seq=>"`seq` int(11) DEFAULT '0'",
);

$duoduo2010 = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  adminname=>"`adminname` varchar(255) DEFAULT NULL",
  adminpass=>"`adminpass` varchar(255) DEFAULT NULL",
  lastlogintime=>"`lastlogintime` datetime DEFAULT NULL",
  lastloginip=>"`lastloginip` varchar(255) DEFAULT NULL",
  loginnum=>"`loginnum` int(11) DEFAULT '0'",
  logintime=>"`logintime` datetime DEFAULT NULL",
  loginip=>"`loginip` varchar(255) DEFAULT NULL",
);

$file = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  path=>"`path` varchar(255) DEFAULT NULL",
  size=>"`size` varchar(255) DEFAULT NULL",
  upload_date=>"`upload_date` varchar(255) DEFAULT NULL",
);

$mall = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  name=>"`name` varchar(20) DEFAULT NULL",
  merchant=>"`merchant` varchar(20) DEFAULT NULL",
  url=>"`url` varchar(255) DEFAULT NULL",
  logo=>"`logo` varchar(255) DEFAULT NULL",
  catid=>"`catid` int(2) DEFAULT NULL",
  fan=>"`fan` varchar(50) DEFAULT NULL",
  hdfk=>"`hdfk` varchar(10) DEFAULT NULL",
  zgfp=>"`zgfp` varchar(10) DEFAULT NULL",
  yfzc=>"`yfzc` varchar(30) DEFAULT NULL",
  ding=>"`ding` int(10) DEFAULT '0'",
  cai=>"`cai` int(10) DEFAULT '0'",
  des=>"`des` varchar(255) DEFAULT '暂无'",
  js=>"`js` text DEFAULT NULL",
  time=>"`time` varchar(30) DEFAULT NULL",
  sort=>"`sort` int(11) DEFAULT '255'",
  yilink=>"yilink` VARCHAR(255) NULL DEFAULT NULL",
  lm=>"`lm` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'yiqifa'"
);

$mall_comment = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  mall_name=>"`mall_name` varchar(50) DEFAULT NULL",
  user_name=>"`user_name` varchar(50) DEFAULT NULL",
  service=>"`service` int(2) DEFAULT NULL",
  product=>"`product` int(2) DEFAULT NULL",
  deliver=>"`deliver` int(2) DEFAULT NULL",
  zf=>"`zf` double DEFAULT NULL",
  comment=>"`comment` text DEFAULT NULL",
  time=>"`time` varchar(20) DEFAULT NULL",
);

$msgset = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  msg=>"`msg` varchar(2000) DEFAULT NULL",
  type=>"`type` varchar(255) DEFAULT NULL",
);

$mall_order = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  order_time=>"`order_time` varchar(20) DEFAULT NULL",
  merchant_id=>"`merchant_id` varchar(20) DEFAULT NULL",
  u_id=>"`u_id` int(11) DEFAULT '0'",
  ddusername=>"`ddusername` varchar(50) DEFAULT NULL",
  order_code=>"`order_code` varchar(20) DEFAULT NULL",
  item_count=>"`item_count` int(5) DEFAULT NULL",
  item_price=>"`item_price` varchar(10) DEFAULT NULL",
  sales=>"`sales` varchar(20) DEFAULT NULL",
  commission=>"`commission` varchar(10) DEFAULT NULL",
  fxje=>"`fxje` varchar(10) DEFAULT NULL",
  bill_yyyymmdd=>"`bill_yyyymmdd` varchar(20) DEFAULT '0'",
  stat_desc=>"`stat_desc` varchar(10) DEFAULT NULL",
  prod_id=>"`prod_id` varchar(255) DEFAULT NULL",
  qrsj=>"`qrsj` varchar(255) DEFAULT NULL",
  product_code=>"`product_code` VARCHAR( 50 ) NULL",
  'unique_id'=>"`unique_id` VARCHAR( 50 ) NULL DEFAULT NULL",
  'lm'=>"`lm` VARCHAR( 50 ) NULL DEFAULT NULL",
);

$mingxi = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  ddusername=>"`ddusername` varchar(255) DEFAULT NULL",
  shijian=>"`shijian` varchar(255) DEFAULT NULL",
  je=>"`je` double DEFAULT '0'",
  addtime=>"`addtime` datetime DEFAULT NULL",
  memo=>"`memo` varchar(500) DEFAULT NULL",
);

$msg = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  title=>"`title` varchar(500) DEFAULT NULL",
  content=>"`content` varchar(6000) DEFAULT NULL",
  addtime=>"`addtime` datetime DEFAULT NULL",
  see=>"`see` int(11) DEFAULT '0'",
  ddusername=>"`ddusername` varchar(255) DEFAULT NULL",
  senduser=>"`senduser` varchar(255) DEFAULT NULL",
);

$shop = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  nick=>"`nick` varchar(255) DEFAULT NULL",
  uid=>"`uid` varchar(255) DEFAULT NULL",
  cid=>"`cid` int(10) DEFAULT NULL",
  consumer_protection=>"`consumer_protection` varchar(10) DEFAULT NULL",
  level=>"`level` int(10) DEFAULT NULL",
  score=>"`score` int(11) DEFAULT NULL",
  total_num=>"`total_num` int(11) DEFAULT NULL",
  good_num=>"`good_num` int(11) DEFAULT NULL",
  city=>"`city` varchar(255) DEFAULT NULL",
  state=>"`state` varchar(255) DEFAULT NULL",
  sid=>"`sid` varchar(255) DEFAULT NULL",
  title=>"`title` varchar(255) DEFAULT NULL",
  pic_path=>"`pic_path` varchar(255) DEFAULT NULL",
  created=>"`created` varchar(255) DEFAULT NULL",
  shop_click_url=>"`shop_click_url` varchar(300) DEFAULT NULL",
  type=>"`type` varchar(5) DEFAULT 'C'",
  addtime=>"`addtime` varchar(255) DEFAULT '2007-05-23'",
  hits=>"`hits` int(11) DEFAULT '0'",
  tuijian=>"`tuijian` int(11) DEFAULT '0'",
  item_score=>"`item_score` varchar(255) DEFAULT '4.8'",
  service_score=>"`service_score` varchar(255) DEFAULT '4.8'",
  delivery_score=>"`delivery_score` varchar(255) DEFAULT '4.8'",
  fanxianlv=>"`fanxianlv` varchar(255) DEFAULT NULL",
  good=>"`good` varchar(255) DEFAULT NULL",
);

$slides = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  pic=>"`pic` varchar(255) DEFAULT NULL",
  url=>"`url` varchar(255) DEFAULT NULL",
  title=>"`title` varchar(100) DEFAULT NULL",
  hide=>"`hide` int(11) DEFAULT '0'",
  addtime=>"`addtime` datetime DEFAULT NULL",
  wz=>"`wz` int(11) DEFAULT '10000'",
);

$tixian = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  ddusername=>"`ddusername` varchar(255) DEFAULT NULL",
  txje=>"`txje` double DEFAULT NULL",
  zfb=>"`zfb` varchar(255) DEFAULT NULL",
  addtime=>"`addtime` datetime DEFAULT NULL",
  addip=>"`addip` varchar(255) DEFAULT NULL",
  txstate=>"`txstate` int(11) DEFAULT '0'",
  realname=>"`realname` varchar(255) DEFAULT NULL",
  mobile=>"`mobile` varchar(255) DEFAULT NULL",
  why=>"`why` varchar(500) DEFAULT NULL",
);

$tradelist = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  pay_time=>"`pay_time` datetime DEFAULT NULL",
  item_title=>"`item_title` varchar(255) DEFAULT NULL",
  shop_title=>"`shop_title` varchar(255) DEFAULT NULL",
  num_iid=>"`num_iid` varchar(255) DEFAULT NULL",
  seller_nick=>"`seller_nick` varchar(255) DEFAULT NULL",
  pay_price=>"`pay_price` varchar(255) DEFAULT NULL",
  commission_rate=>"`commission_rate` varchar(255) DEFAULT NULL",
  commission=>"`commission` varchar(255) DEFAULT NULL",
  item_num=>"`item_num` varchar(255) DEFAULT NULL",
  trade_id=>"`trade_id` varchar(255) DEFAULT NULL",
  outer_code=>"`outer_code` varchar(255) DEFAULT NULL",
  qrsj=>"`qrsj` datetime DEFAULT NULL",
  fxje=>"`fxje` double DEFAULT '0'",
  checked=>"`checked` INT( 1 ) NULL DEFAULT '0'",
  ddjt=>"`ddjt` VARCHAR( 255 ) NULL",
);

$user = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  ddusername=>"`ddusername` varchar(255) DEFAULT NULL",
  ddpassword=>"`ddpassword` varchar(255) DEFAULT NULL",
  tbusername=>"`tbusername` varchar(255) DEFAULT NULL",
  regtime=>"`regtime` datetime DEFAULT NULL",
  loginnum=>"`loginnum` int(11) DEFAULT '0'",
  lastlogintime=>"`lastlogintime` datetime DEFAULT NULL",
  lasttixian=>"`lasttixian` datetime DEFAULT NULL",
  zfb=>"`zfb` varchar(255) DEFAULT NULL",
  email=>"`email` varchar(255) DEFAULT NULL",
  money=>"`money` double DEFAULT '0'",
  txstate=>"`txstate` int(11) DEFAULT '0'",
  dengji=>"`dengji` int(11) DEFAULT '0'",
  tjr=>"`tjr` varchar(255) DEFAULT NULL",
  mobile=>"`mobile` varchar(255) DEFAULT NULL",
  qq=>"`qq` varchar(255) DEFAULT NULL",
  pass_question=>"`pass_question` varchar(250) DEFAULT NULL",
  pass_answer=>"`pass_answer` varchar(250) DEFAULT NULL",
  yitixian=>"`yitixian` double DEFAULT '0'",
);

$websetting = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  fxbl=>"`fxbl` double DEFAULT '0.5'",
  fxbl2=>"`fxbl2` double DEFAULT '0.6'",
  fxbl3=>"`fxbl3` double DEFAULT '0.7'",
  fxbl4=>"`fxbl4` double DEFAULT '0.8'",
  mallfxbl1=>"`mallfxbl1` double DEFAULT '0.5'",
  mallfxbl2=>"`mallfxbl2` double DEFAULT '0.6'",
  mallfxbl3=>"`mallfxbl3` double DEFAULT '0.7'",
  mallfxbl4=>"`mallfxbl4` double DEFAULT '0.8'",
  tgbl=>"`tgbl` double DEFAULT '0.1'",
  webtitle=>"`webtitle` varchar(250) DEFAULT NULL",
  webdesc=>"`webdesc` varchar(250) DEFAULT NULL",
  keyword=>"`keyword` varchar(2000) DEFAULT NULL",
  description=>"`description` varchar(2000) DEFAULT NULL",
  url=>"`url` varchar(100) DEFAULT NULL",
  surl=>"`surl` varchar(100) DEFAULT NULL",
  email=>"`email` varchar(100) DEFAULT NULL",
  icp=>"`icp` varchar(100) DEFAULT NULL",
  tongji=>"`tongji` varchar(1000) DEFAULT NULL",
  qq=>"`qq` varchar(50) DEFAULT NULL",
  webnick=>"`webnick` varchar(100) DEFAULT NULL",
  emsg=>"`emsg` varchar(1500) DEFAULT NULL",
  gonggao=>"`gonggao` longtext",
  renzheng=>"`renzheng` varchar(1000) DEFAULT NULL",
  tixianje=>"`tixianje` double DEFAULT '10'",
  txxz=>"`txxz` double DEFAULT '0'",
  zhucesong=>"`zhucesong` double DEFAULT '0'",
  zhucesonglevel=>"`zhucesonglevel` int(11) DEFAULT '0'",
  liebiao=>"`liebiao` varchar(10) DEFAULT '0'",
  wjt=>"`wjt` varchar(10) DEFAULT '0'",
  morensort=>"`morensort` varchar(255) DEFAULT 'commissionNum_desc'",
  moban=>"`moban` varchar(50) DEFAULT 'default'",
  hcopen=>"`hcopen` varchar(10) DEFAULT '0'",
  hctime=>"`hctime` varchar(10) DEFAULT '10'",
  dengji1=>"`dengji1` int(11) DEFAULT '20'",
  dengji2=>"`dengji2` int(11) DEFAULT '50'",
  dengji3=>"`dengji3` int(11) DEFAULT '100'",
  shopcj=>"`shopcj` int(11) DEFAULT '1'",
  shopcj_slevel=>"`shopcj_slevel` int(11) DEFAULT '11'",
  shopcj_elevel=>"`shopcj_elevel` int(11) DEFAULT '20'",
  pagesize=>"`pagesize` varchar(10) DEFAULT '20'",
  smtp_host=>"`smtp_host` varchar(100) DEFAULT NULL",
  smtp_user=>"`smtp_user` varchar(100) DEFAULT NULL",
  smtp_pw=>"`smtp_pw` varchar(100) DEFAULT NULL",
  smtp_open=>"`smtp_open` varchar(10) DEFAULT 'off'",
  fxbname=>"`fxbname` varchar(100) DEFAULT '返现宝'",
  hotword=>"`hotword` varchar(100) DEFAULT '热卖'",
  webclose=>"`webclose` int(11) DEFAULT '0'",
  webclosemsg=>"`webclosemsg` varchar(1000) DEFAULT '网站维护中，请稍后再来...'",
  webtype=>"`webtype` int(11) DEFAULT '1'",
  cha=>"`cha` int(11) DEFAULT '0'",
  apijk=>"`apijk` int(11) DEFAULT '0'",
  apisize=>"`apisize` int(11) DEFAULT '50'",
  mallzh=>"`mallzh`  varchar(100) DEFAULT NULL",
  mallmm=>"`mallmm`  varchar(100) DEFAULT NULL",
  mallwzbh=>"`mallwzbh`  varchar(100) DEFAULT NULL",
  uc=>"`uc` int(11) DEFAULT '0'",
  gettime=>"`gettime`  varchar(20) DEFAULT '0'",
  miyue=>"`miyue` VARCHAR( 50 ) NULL DEFAULT NULL",
);

$taobaoset = array(
  id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  appKey=>"`appKey` varchar(255) DEFAULT NULL",
  appSecret=>"`appSecret` varchar(255) DEFAULT NULL",
  appkey2=>"`appkey2` varchar(255) DEFAULT NULL",
  appsecret2=>"`appsecret2` varchar(255) DEFAULT NULL",
  appkey3=>"`appkey3` varchar(255) DEFAULT NULL",
  appsecret3=>"`appsecret3` varchar(255) DEFAULT NULL",
  appkey4=>"`appkey4` varchar(255) DEFAULT NULL",
  appsecret4=>"`appsecret4` varchar(255) DEFAULT NULL",
  appkey5=>"`appkey5` varchar(255) DEFAULT NULL",
  appsecret5=>"`appsecret5` varchar(255) DEFAULT NULL",
  userpid=>"`userpid` varchar(255) DEFAULT NULL",
  usernick=>"`usernick` varchar(255) DEFAULT NULL",
  seckey=>"`seckey` varchar(255) DEFAULT NULL",
);
  
$yqlj = array(
  Id=>"`Id` int(11) NOT NULL AUTO_INCREMENT",
  url=>"`url` varchar(255) DEFAULT NULL",
  webname=>"`webname` varchar(255) DEFAULT NULL",
  addtime=>"`addtime` datetime DEFAULT NULL",
  leibie=>"`leibie` int(11) DEFAULT '0'",
  pic=>"`pic` varchar(255) DEFAULT ''",
  wz=>"`wz` int(11) DEFAULT '0'",
);

$malltype = array(
  id=>"`id` int(11) NOT NULL AUTO_INCREMENT",
  typename=>"`typename` varchar(200) DEFAULT ''",
  typecode=>"`typecode` varchar(200) DEFAULT ''",  
  sort=>"`sort` int(11) DEFAULT '0'",
);

function repair_table($table){
	global $ad,$article,$category,$duoduo2010,$file,$mall,$mall_comment,$msgset,$mall_order,$mingxi,$msg,$shop,$slides,$tixian,$tradelist,$user,$websetting,$taobaoset,$yqlj,$malltype,$BIAOTOU;
	foreach($$table as $myfield){
		$subsql=$subsql.$myfield.",";
	}
	$sql="CREATE TABLE `".$BIAOTOU.$table."`(".$subsql." PRIMARY KEY (`Id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
	mysql_query($sql);
	echo " <font color=#ff0000>已修复</font>";
}

function repair_field($retable,$field){
	global $ad,$article,$category,$duoduo2010,$file,$mall,$mall_comment,$msgset,$mall_order,$mingxi,$msg,$shop,$slides,$tixian,$tradelist,$user,$websetting,$taobaoset,$yqlj,$malltype,$BIAOTOU;
	if($retable=="ad"){$table=$ad;}
	if($retable=="article"){$table=$article;}
	if($retable=="category"){$table=$category;}
	if($retable=="duoduo2010"){$table=$duoduo2010;}
	if($retable=="file"){$table=$file;}
	if($retable=="mall"){$table=$mall;}
	if($retable=="mall_comment"){$table=$mall_comment;}
	if($retable=="msgset"){$table=$msgset;}
	if($retable=="mall_order"){$table=$mall_order;}
	if($retable=="mingxi"){$table=$mingxi;}
	if($retable=="msg"){$table=$msg;}
	if($retable=="shop"){$table=$shop;}
	if($retable=="slides"){$table=$slides;}
	if($retable=="tixian"){$table=$tixian;}
	if($retable=="tradelist"){$table=$tradelist;}
	if($retable=="user"){$table=$user;}
	if($retable=="websetting"){$table=$websetting;}
	if($retable=="taobaoset"){$table=$taobaoset;}
	if($retable=="yqlj"){$table=$yqlj;}
	if($retable=="malltype"){$table=$malltype;}
	$sql="ALTER TABLE `".$BIAOTOU.$retable."` add ".$table["$field"].";";
	mysql_query($sql);
	echo " <font color=#ff0000>已修复</font><br>";echo $sql;
}

echo '<span style="font-weight:bold; color:#ff6600; font-size:12px;">开始检测数据库基础表......</span><br>';
$rs=mysql_query("show tables like '".$BIAOTOU."ad';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."ad ...";repair_table("ad");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."article';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."article... ";repair_table("article");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."category';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."category... ";repair_table("category");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."file';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."file... ";repair_table("file");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall... ";repair_table("mall");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall_comment';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall_comment... ";repair_table("mall_comment");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall_order';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall_order... ";repair_table("mall_order");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."malltype';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."malltype... ";repair_table("malltype");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mingxi';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mingxi... ";repair_table("mingxi");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."msg';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."msg... ";repair_table("msg");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."msgset';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."msgset... ";repair_table("msgset");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."shop';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."shop... ";repair_table("shop");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."slides';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."slides... ";repair_table("slides");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."taobaoset';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."taobaoset... ";repair_table("taobaoset");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."tixian';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."tixian... ";repair_table("tixian");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."tradelist';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."tradelist... ";repair_table("tradelist");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."user';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."user... ";repair_table("user");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."websetting';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."websetting... ";repair_table("websetting");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."yqlj';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."yqlj... ";repair_table("yqlj");$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."duoduo2010';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."duoduo2010... ";repair_table("duoduo2010");$i++;}

if($i==0){echo " 数据表正常！";}

echo '<span style="font-weight:bold; color:#ff6600; font-size:12px;"><br>开始检测数据库基础表表内字段......</span><br>';
$rs=mysql_query("show fields from `".$BIAOTOU."ad`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","content","adtype","addtime");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."ad中缺少字段".$myfield."... ";repair_field("ad",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."article`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","cid","title","subtitle","att","pic","source","author","resume","pubdate","content","hits","created_by","created_date","delete_session_id","ontop","hot");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."article中缺少字段".$myfield."... ";repair_field("article",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."category`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","pid","name","description","seq");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."category中缺少字段".$myfield."... ";repair_field("category",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."duoduo2010`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","adminname","adminpass","lastlogintime","lastloginip","loginnum","logintime","loginip");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."duoduo2010中缺少字段".$myfield."... ";repair_field("duoduo2010",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."file`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","path","size","upload_date");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."file中缺少字段".$myfield."... ";repair_field("file",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","name","merchant","url","logo","catid","fan","hdfk","zgfp","yfzc","ding","cai","des","js","time","sort","yilink","lm");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall中缺少字段".$myfield."... ";repair_field("mall",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall_comment`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","mall_name","user_name","service","product","deliver","zf","comment","time");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall_comment中缺少字段".$myfield."... ";repair_field("mall_comment",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall_order`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","order_time","merchant_id","u_id","ddusername","order_code","item_count","item_price","sales","commission","fxje","bill_yyyymmdd","stat_desc","prod_id","qrsj","product_code","unique_id","lm");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall_order中缺少字段".$myfield."... ";repair_field("mall_order",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."malltype`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","typename","typecode","sort");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."ad中缺少字段".$myfield."... ";repair_field("ad",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mingxi`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","shijian","je","addtime","memo");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mingxi中缺少字段".$myfield."... ";repair_field("mingxi",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."msg`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","title","content","addtime","see","ddusername","senduser");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."msg中缺少字段".$myfield."... ";repair_field("msg",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."msgset`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","msg","type");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."msgset中缺少字段".$myfield."... ";repair_field("msgset",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."shop`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","nick","uid","cid","consumer_protection","level","score","total_num","good_num","city","state","sid","title","pic_path","created","shop_click_url","type","addtime","hits","tuijian","item_score","service_score","delivery_score","fanxianlv","good");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."shop中缺少字段".$myfield."... ";repair_field("shop",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."slides`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","pic","url","title","hide","addtime","wz");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."slides中缺少字段".$myfield."... ";repair_field("slides",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."taobaoset`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","appKey","appSecret","appkey2","appsecret2","appkey3","appsecret3","appkey4","appsecret4","appkey5","appsecret5","userpid","usernick","seckey");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."taobaoset中缺少字段".$myfield."... ";repair_field("taobaoset",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."tixian`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","txje","zfb","addtime","addip","txstate","realname","mobile","why");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."tixian中缺少字段".$myfield."... ";repair_field("tixian",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."tradelist`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","pay_time","item_title","shop_title","num_iid","seller_nick","pay_price","commission_rate","commission","item_num","trade_id","outer_code","qrsj","fxje","checked","ddjt");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."tradelist中缺少字段".$myfield."... ";repair_field("tradelist",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."user`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","ddpassword","tbusername","regtime","loginnum","lastlogintime","lasttixian","zfb","email","money","txstate","dengji","tjr","mobile","qq","pass_question","pass_answer","yitixian");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."user中缺少字段".$myfield."... ";repair_field("user",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."websetting`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","fxbl","fxbl2","fxbl3","fxbl4","mallfxbl1","mallfxbl2","mallfxbl3","mallfxbl4","tgbl","webtitle","webdesc","keyword","description","url","surl","email","icp","tongji","qq","webnick","emsg","gonggao","renzheng","tixianje","txxz","zhucesong","zhucesonglevel","liebiao","wjt","morensort","moban","hcopen","hctime","dengji1","dengji2","dengji3","shopcj","shopcj_slevel","shopcj_elevel","pagesize","smtp_host","smtp_user","smtp_pw","smtp_open","fxbname","hotword","webclose","webclosemsg","webtype","cha","apisize","mallzh","mallmm","mallwzbh","uc","apijk","gettime","miyue");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."websetting中缺少字段".$myfield."... ";repair_field("websetting",$myfield);$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."yqlj`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","url","webname","addtime","leibie","pic","wz");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."yqlj中缺少字段".$myfield."... ";repair_field("yqlj",$myfield);$j++;}
}

if($j==0){echo " 数据表内字段正常！<br>";}

mysql_close($link);
?>
</td>
</tr>
<tr>
<td style="padding-left:10px; color:#999999; line-height:25px;"><br><br>如果您的数据库缺少字段，可能是你的数据库被破坏或没有运行升级文件。<br>
1、如果你是升级后出现：说明你没有运行升级文件。<br>
2、如果是平时出现：可能数据库被破坏。<br>
3、如果是恢复数据后出现，可能你的数据库被还原到老版本了。<br>
4、如果无法确定提交论坛寻求帮助。
</td>
</tr>
</table>
</body>
</html>